<template>
<div style="background: darkgray">

  {{nameee}} <br>
  {{tnameee}}登录成功
  <div style="background:#44B6AE; width: 2032px;height:100px" >
    <h1 style="color: aliceblue;" >
      成裕生产管理系统
    </h1>
  </div>
  <div  class="tools_bar">
    <a title @click="sx" class="tools_btn">
        <span class   >
          <b style="background: url('')  50% 4px no-repeat;  ">
             刷新
          </b>
        </span>
    </a>
    <a title @click="pdf" class="tools_btn">
        <span class   >
          <b style="background: url('')  50% 4px no-repeat;  ">
             pdf生成
          </b>
        </span>
    </a>
    <a title @click="openadd" class="tools_btn">
        <span class   >
          <b style="background: url('https://mes.chengyuyun.top/Themes/images/16/application_add.png')  50% 4px no-repeat;  ">
             新增
          </b>
        </span>
    </a>
  </div>
  <el-form :inline="true" :model="stu" class="demo-form-inline">
    <el-form-item label="仓库编号">
      <el-input v-model="stu.bname" placeholder="仓库编号"></el-input>
    </el-form-item>
    <el-form-item label="仓库名称">
      <el-input v-model="stu.cname" placeholder="仓库名称"></el-input>
    </el-form-item>
    <el-form-item label="仓库位置">
      <el-input v-model="stu.address" placeholder="仓库位置"></el-input>
    </el-form-item>
    <el-form-item label="备注">
      <el-input v-model="stu.bz" placeholder="备注"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="list" style="background: dimgrey">搜索</el-button>
    </el-form-item>

  </el-form>
  <template>
    <el-table
        :data="table"
        border
        style="width: 100%">
      <el-table-column
          prop="id"
          label="编号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="bname"
          label="仓库编号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="cname"
          label="仓库名称">
      </el-table-column>
      <el-table-column
          prop="address"
          label="仓库位置">
      </el-table-column>
      <el-table-column
          prop="bz"
          label="备注">
      </el-table-column>
      <el-table-column
          prop="anddate"
          label="时间">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作"
          width="100">
        <template slot-scope="scope">
          <el-button @click="xg(scope.row)" type="text" size="small">修改</el-button>
          <el-button @click="del(scope.row)" type="text" size="small">删除</el-button>
          <el-button @click="xq(scope.row)" type="text" size="small">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
  </template>
  <el-pagination
      @current-change="getpage"
      :page-size="stu.pageSize"
      :page-count="stu.pageNum"
      layout="total, prev, pager, next"
      :total="total">
  </el-pagination>
  <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
    <el-form :model="stt">
      <el-form-item label="编码" :label-width="formLabelWidth">
        <el-input v-model="stt.bname" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="仓库名称" :label-width="formLabelWidth">
        <el-input v-model="stt.cname" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="地址" :label-width="formLabelWidth">
        <el-input v-model="stt.address" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="备注" :label-width="formLabelWidth">
        <el-input v-model="stt.bz" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="时间" :label-width="formLabelWidth">
        <el-input  v-model="stt.anddate" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="add">确 定</el-button>
    </div>
  </el-dialog>
</div>
</template>

<script>
export default {
  name: "StuView",
  data() {
    return {
      nameee:sessionStorage.getItem("nameee"),
      tnameee:sessionStorage.getItem("tnameee"),
      stt:{},
      dialogFormVisible:false,
      formLabelWidth:"100px",
      stu:{
        pageNum:1,
        pageSize:3,
      },
      table:[],
      total:0,
    }
  }, methods: {
    xq(id){
      this.axios.get("user/stu/xq?id="+id.id).then(res=>{
         sessionStorage.setItem("cname",res.data.data.cname);
        sessionStorage.setItem("anddate",res.data.data.anddate);
        sessionStorage.setItem("address",res.data.data.address);
        sessionStorage.setItem("bz",res.data.data.bz);
        sessionStorage.setItem("id",res.data.data.id);
        sessionStorage.setItem("bname",res.data.data.bname);
        this.$router.push('stuxq')

      })
    },
    pdf(){
      window.location='http://localhost:8009/stu/pdf';
    },
    sx(){
      this.$router.push('stu');
      this.list();
      this.$message.success("刷新成功")

    },
    del(id){
      this.axios.get("stu/del?id="+id.id).then(res=>{
        if(res.data.code==1){
          this.$message.success(res.data.msg);
           this.list();
        }else{
          this.$message.error(res.data.msg);
        }
      })
    },
    xg(row){
      this.dialogFormVisible=true;
      this.stt=row;
    },
    openadd(){
      this.dialogFormVisible=true;
    },
    add(){
      this.axios.get("stu/add",{params:this.stt}).then(res=>{
        if(res.data.code==1){
          this.$message.success(res.data.msg);
          this.dialogFormVisible=false;
          this.list();
        }else{
          this.$message.error(res.data.msg);
        }
      })
    },
    getpage(page){
      this.stu.pageNum=page;
      this.list();
    },
    list(){
      this.axios.get("stu/list",{params:this.stu}).then(res=>{
         this.total=res.data.total;
         this.table=res.data.list;
      })
    }

  }, created() {
    this.list();
  }
}
</script>

<style scoped>
.tools_btn{
  cursor: pointer;
  float: left;
  display: block;
  margin: 3px 3px 0;
  padding: 0 0 0 10px;
  height: 39px;
  overflow: hidden;
}
.tools_bar{
  padding-left: 5px;
  height: 45px;
  border: #ccc 1px solid;
  background: #F7F7F7;
}
.tools_btn span b{
  font-weight: normal;
  display: block;
  padding: 22px 0 5px;
  line-height: 15px
}
</style>